From 54fd3bbb557e79e1a6cb36a4b1c5003f747a19e5 Mon Sep 17 00:00:00 2001 From: justbur Date: Sun, 16 Aug 2015 18:19:30 -0400 Subject: [PATCH] Add helper function for prefix titles --- which-key.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/which-key.el b/which-key.el index 444ec11ae81..4ecd4d30811 100644 --- a/which-key.el +++ b/which-key.el @@ -478,6 +478,19 @@ addition KEY-SEQUENCE REPLACEMENT pairs) to apply." (setcdr (assq mode which-key-key-based-description-replacement-alist) mode-alist) (push (cons mode mode-alist) which-key-key-based-description-replacement-alist)))) +;;;###autoload +(defun which-key-add-prefix-title (key-seq-str name &optional force) + "Add title for KEY-SEQ-STR given by TITLE. +FORCE, if non-nil, will add the new title even if one already +exists. KEY-SEQ-STR should be a key sequence string suitable for +`kbd' and NAME should be a string." + (interactive) + (let ((key-seq-lst (listify-key-sequence (kbd key-seq-str)))) + (if (and (null force) + (assoc key-seq-lst which-key-prefix-title-alist)) + (message "which-key: Prefix title not added. A title exists for this prefix.") + (push (cons key-seq-lst name) which-key-prefix-title-alist)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Functions for computing window sizes -- 2.30.2